<template>
  <MkQueryContainer>
    <template #header>
      <MkForm ref="queryForm" :inline="true">
        <el-form-item label="关键字">
          <!-- <el-input @keyup.enter.native="search" v-model="searchParam.keyword" clearable /> -->
        </el-form-item>
        <el-form-item>
          <MkButtonQuery @click="search"> </MkButtonQuery>
          <MkButtonAdd @click="add"></MkButtonAdd>
        </el-form-item>
      </MkForm>
    </template>
    <MkTable :data="tableData" v-loading="loading" @row-dblclick="edit" row-key="id">
      <MkColumnIndex />
      <MkColumn prop="pId" label="父节点" />
      <MkColumn prop="mingCheng" label="名称" />
      <MkColumn prop="daLei" label="血液大类" />
      <MkColumn prop="yongXueLeiXing" label="用血类型" />
      <MkColumn prop="keBie" label="科别(内科/外科)" />
      <MkColumn prop="functionBody" label="合理性判断函数" />
      <MkColumn prop="orderNo" label="排序" />
      <MkColumn prop="remark" label="备注" />
      <MkColumnIsEnabled />
      <MkColumnOption @show="edit" :isMore="false" />
    </MkTable>
    <!-- <MkPagination v-model:page="searchParam.page" v-model:pageSize="searchParam.pageSize" :total="total"
      @query="search" /> -->
    <EditPage ref="editPageRef" @query="search" />
  </MkQueryContainer>
</template>

<script lang='ts' setup name="BasShuXueZhiZheng">
// 血液品种资料
import { BasShuXueZhiZhengApi, BasShuXueZhiZhengOutput } from '/@/api/bas/BasShuXueZhiZheng';
// import { usePageQuery } from '/@/hooks/usePageQuery'

import EditPage from './edit.vue'

import { initShuXueZhiZhengForce, getBasShuXueZhiZhengTree } from "/@/stores/baseInfo/BasShuXueZhiZheng";

// const { searchParam, total, tableData, loading, search } = usePageQuery<BasShuXueZhiZhengOutput>(BasShuXueZhiZhengApi.all)

const tableData = ref<BasShuXueZhiZhengOutput[]>();
const loading = ref<Boolean>(false);

const editPageRef = ref();

const search = async (isSubmit = false) => {
  loading.value = true;
  if(isSubmit) {
    await initShuXueZhiZhengForce();
  }
  tableData.value = await getBasShuXueZhiZhengTree();
  loading.value = false;
}

onMounted(() => {
  search();
})

const add = () => {
  editPageRef.value.open();
}

const edit = (row: any) => {
  editPageRef.value.open(row);
}
</script>

<style lang='scss' scoped></style>